package com.yxq.mdt.app.modules.video.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.video.bean.AdvertBean;
import com.yxq.mdt.app.modules.video.bean.ChannelListBean;
import com.yxq.mdt.app.modules.video.bean.MLUserList;
import com.yxq.mdt.app.modules.video.model.MainVideoModel;
import com.yxq.mdt.app.net.ApiModel;

import java.util.List;

public class MainVideoPresenter extends BasePresenter<IMainVideoContract.View, MainVideoModel> implements IMainVideoContract.Presenter {

    /**
     * 如果当前页面同时需要 Model 层和 View 层,则使用此构造函数(默认)
     *
     * @param rootView
     * @param model
     */
    public MainVideoPresenter(IMainVideoContract.View rootView, MainVideoModel model) {
        super(rootView, model);
    }

    public void getChannelConfig(int configType) {

        mBaseModel.getChannelConfig(configType,new ApiModel.CommonCallback<List<ChannelListBean>>() {
            @Override
            public void onSuccess(List<ChannelListBean> channelListBeanList) {
                mRootView.onChannelListSuccess(channelListBeanList);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onChannelListFailed(errMsg);
            }
        });
    }

    public void getMlList(int pageNum, int pageSize, int queryType, String mlChannel, String lng, String lat) {

        mBaseModel.getMlList(pageNum, pageSize, queryType, mlChannel, lng, lat, new ApiModel.CommonCallback<MLUserList>() {
            @Override
            public void onSuccess(MLUserList channelListBeanList) {
                mRootView.onUserListSuccess(channelListBeanList);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onUserListFailed(errMsg);
            }
        });
    }

    public void advertByPosition(String position) {

        mBaseModel.advertByPosition(position, new ApiModel.CommonCallback<AdvertBean>() {
            @Override
            public void onSuccess(AdvertBean advertBean) {
                mRootView.onAdvertSuccess(advertBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onAdvertSuccessFailed(errMsg);
            }
        });
    }
}
